package com.hgy.carsb.controller;

import com.hgy.carsb.entity.StructureDetail;
import com.hgy.carsb.service.StructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class StructureController {
    @Autowired
    private StructureService structureService;

    private int year=2020;
    private int month=4;

    @GetMapping("/structure")
    public List<StructureDetail> getDetail(){
        List<StructureDetail> list = new ArrayList<>();
        String[] code = {"advertising", "freight", "msalary", "promotion", "propaganda", "quality"};
        for (int i=0; i<code.length; i++){
            list.add(structureService.getDetail(year, month, code[i], "FAW"));
        }
        return list;
    }
}
